#ifndef _DEBUG_H
#define _DEBUG_H

//------------------------------------------------------------------------------

#include <stdio.h>
#include <unistd.h>

//------------------------------------------------------------------------------

#ifndef NDEBUG

//------------------------------------------------------------------------------

#define IDEBUG \
    do { \
        fprintf(stderr, "%s:%d:%s()\n", __FILE__, __LINE__, __func__); \
        usleep(200000); \
    } while (0)

//------------------------------------------------------------------------------

#define DEBUG(fmt, ...) \
    do { \
        fprintf(stderr, "%s:%d:%s(): " fmt "\n", __FILE__, __LINE__, __func__,\
                 __VA_ARGS__); \
        usleep(200000); \
    } while (0)

//------------------------------------------------------------------------------

#define QDEBUG(fmt, ...) \
    do { \
        fprintf(stderr, fmt, __VA_ARGS__); \
    } while (0)

//------------------------------------------------------------------------------

#else 

//------------------------------------------------------------------------------

#define IDEBUG
#define DEBUG(fmt, ...)
#define QDEBUG(fmt, ...)

//------------------------------------------------------------------------------

#endif

//------------------------------------------------------------------------------

#endif //_DEBUG_H
